package com.witmed.service.impl;

import java.util.List;

import com.witmed.dao.UserDao;
import com.witmed.dao.impl.UserDaoImpl;
import com.witmed.entity.Appointment;
import com.witmed.entity.UserInfo;
import com.witmed.service.UserService;

public class UserServiceImpl implements UserService{

	UserDao userDao = new UserDaoImpl();
	
	@Override
	public List<UserInfo> queryAll() {
		return userDao.queryAll();
	}
	
	@Override
	public List<UserInfo> findByUserName(String userName) {
		return userDao.queryByUserName(userName);
	}
	
	@Override
	public List<UserInfo> findByUserTel(String userTel) {
		return userDao.queryByUserTel(userTel);
	}
	
	@Override
	public List<UserInfo> loginByUserNameAndPassword(String userName,String userPassword) {
		return userDao.queryByUserNameAndPassword(userName, userPassword);
	}
	
	@Override
	public List<UserInfo> loginByUserTelAndPassword(String userTel,String userPassword) {
		return userDao.queryByUserTelAndPassword(userTel, userPassword);
	}


	@Override
	public boolean insert(UserInfo user) {
		return userDao.insert(user)==1?true:false;
	}

	@Override
	public boolean update(UserInfo user) {
		return userDao.update(user)==1?true:false;
	}
	
	@Override
	public boolean updateByTel(UserInfo user) {
		return userDao.updateByTel(user)==1?true:false;
	}

	@Override
	public boolean delete(int userId) {
		return userDao.delete(userId)==1?true:false;
	}
	/**
	 * 用户查询个人信息通过用户id或用户的手机号
	 * @author ChenYouming 
	 * @param number  传入的查询条件值
	 * @return 返回一个用户集合
	 */
	@Override
	public List<UserInfo> queryByUserIdOrUserTel(String number) {
		List<UserInfo> list = userDao.queryByUserIdOrUserTel(number);
		return list;
	}
	/**
	 * 用户查询个人预约信息通过问诊记录id或用户id
	 * @author ChenYouming 
	 * @param number传入的查询条件值
	 * @return 返回一个问诊记录集合
	 */
	@Override
	public List<Appointment> queryByUserId(String number) {
		List<Appointment> list = userDao.queryByUserId(number);
		return list;
	}
	
	
	

}
